
<template>
  <div class="common-layout">
    <el-container>
      <el-header class="custom-header">
        <div class="header-content">
          <div class="logo">后台管理系统</div>
          <div class="user-info">
            <span>欢迎您，管理员：{{ adminName }}</span>
            <el-button @click="logout" type="text">退出登录</el-button>
          </div>
        </div>
      </el-header>
      <el-container>
        <el-aside  class="sidebar">
          <el-menu default-active="2" class="el-menu-vertical-demo" router>
            <el-menu-item v-if="userPower === '0'" index="webdate">
              <el-icon><icon-menu /></el-icon>
              <span>网站数据</span>
            </el-menu-item>

            <el-menu-item index="pcinfo" v-if="userPower === '2'"
                >咨询师</el-menu-item
              >
              <el-menu-item index="pcyuyue" v-if="userPower === '2'"
                  >预约列表</el-menu-item
                >
            <!--用户管理-->
            <el-sub-menu index="1">
              <template #title>
                <span>用户管理</span>
                <el-icon><location /></el-icon>
              </template>
              <el-menu-item index="usercontrol" v-if="userPower === '0'"
                >用户列表</el-menu-item
              >
              <!-- <el-menu-item index="pcinfo" v-if="userPower === '2'"
                >个人信息管理</el-menu-item
              > -->
            </el-sub-menu>
            <!--咨询师管理-->
            <el-sub-menu index="2">
              <template #title>
                <span>咨询师管理</span>
                <el-icon><location /></el-icon>
              </template>
              <el-menu-item index="zixunshicontrol" v-if="userPower === '0'"
                >咨询师列表</el-menu-item
              >

            </el-sub-menu>
            <!--文章管理-->
            <el-sub-menu index="3" >
              <template #title>
                <span> 文章管理</span>
                <el-icon><location /></el-icon>
              </template>
                <el-menu-item index="pagecontrol" v-if="userPower === '0'"
                  >文章列表</el-menu-item
                >
                <el-menu-item index="articlescontrol" v-if="userPower === '0'"
                  >文章类别</el-menu-item
                >
            </el-sub-menu>
             <!--问卷管理--> 
            <el-sub-menu index="4" >
              <template #title>
                <span>问卷管理</span>
                <el-icon><location /></el-icon>
              </template>
                <el-menu-item index="testcontrol" v-if="userPower === '0'"
                  >问卷题库一</el-menu-item
                >
                <el-menu-item index="testcontrol2" v-if="userPower === '0'"
                  >问卷题库二</el-menu-item
                >
                <el-menu-item index="testcontrol3" v-if="userPower === '0'"
                  >问卷题库三</el-menu-item
                >
                <el-menu-item index="wenticlass" v-if="userPower === '0'"
                  >问题分类</el-menu-item
                >
                <el-menu-item index="testcheck" v-if="userPower === '0'"
                  >测评管理</el-menu-item
                >
            </el-sub-menu>
            <!--预约管理--> 
            <el-sub-menu index="5" >
              <template #title>
                <span>预约管理</span>
                <el-icon><location /></el-icon>
              </template>
                <el-menu-item index="yuyuecontrol" v-if="userPower === '0'"
                  >预约列表</el-menu-item
                >
            </el-sub-menu>

              <!--预约管理--> 
              <el-sub-menu index="6" >
              <template #title>
                
                <span>问答管理</span>
                <el-icon><location /></el-icon>
              </template>
                <el-menu-item index="wendacontrol" v-if="userPower === '0'"
                  >问答列表</el-menu-item
                >
            </el-sub-menu>
            <!-- <el-menu-item v-if="userPower === '0'" index="yuyuecontrol">
              <el-icon><icon-menu /></el-icon>
              <span>预约管理</span>
            </el-menu-item>
            <el-menu-item v-if="userPower === '2'" index="pcyuyue">
              <el-icon><icon-menu /></el-icon>
              <span>预约管理</span> -->
            <!-- </el-menu-item> -->
            <!-- <el-menu-item v-if="userPower === '0'" index="wendacontrol">
              <el-icon><icon-menu /></el-icon>
              <span>问答管理</span>
            </el-menu-item> -->
          </el-menu>
        </el-aside>
        <el-main class="main-content">
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>


export default {
  data() {
    return {
      adminName: "",
      routerList: [],
      userPower: localStorage.getItem("userPower"),
    };
  },
  mounted() {
    this.adminName = localStorage.getItem("adminName");
    this.routerList = this.$router.getRoutes();
    this.routerList = this.routerList.filter(
      (item) => item.meta.power == this.userPower
    );
  },
  methods: {
    logout() {
      localStorage.removeItem("adminName");
      localStorage.removeItem("token");
      localStorage.removeItem("userPower");
      this.$router.push("/");
    },
  },
};
</script>

<style >
.el-aside {
  background-color: #eee;
  height: 100vh;
  width: auto;
}
.el-menu {
  width: 200px;
  background-color: #eee;
}
.common-layout {
  font-family: "Arial", sans-serif;
}

.custom-header {
  background-color: #f8f8f7;
  color: #333;
  border-bottom: 1px solid #d2d2d7;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
}

.logo {
  font-size: 1.8em;
  font-weight: bold;
  color: #333;
}

.user-info {
  display: flex;
  align-items: center;
  font-size: 0.9em;
}

.user-info span {
  margin-right: 10px;
  color: #666;
}

.el-button {
  color: #007aff;
}

.sidebar {
  background-color: #fafafa;
  border-right: 1px solid #d2d2d7;

}

.el-menu-vertical-demo {
  background-color: black(219, 214, 214, 0.292);
}

.el-menu-item {
  color: #333333;  
}

.el-menu-item:hover {
  background-color: #f0f0f5;
}

.main-content {
  padding: 21px;
  background-color: #fff;
}

</style>